﻿using ELab.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ELab.Communication.Messages.ControllerMessages
{
    public class GeneralResponseMessage : ControlMessage
    {
        /// <summary>
        /// Gets MessageTypeId for RemoveApplicationResponseMessage.
        /// </summary>
        public override int MessageTypeId
        {
            get { return ControlMessageFactory.MessageTypeIdGeneralResponseMessage; }
        }

        /// <summary>
        /// ID of message request
        /// </summary>
        public int RequestMessageId { get; set; }

        /// <summary>
        /// True, if doing successfully.
        /// </summary>
        public bool IsSuccess { get; set; }

        /// <summary>
        /// If Removed = True then "Success", else error message.
        /// </summary>
        public string ResultMessage { get; set; }

        /// <summary>
        /// Serializes this message.
        /// </summary>
        /// <param name="serializer">Serializer used to serialize objects</param>
        public override void Serialize(IELabSerializer serializer)
        {
            base.Serialize(serializer);
            serializer.WriteInt32(RequestMessageId);
            serializer.WriteBoolean(IsSuccess);
            serializer.WriteStringUTF8(ResultMessage);
        }

        /// <summary>
        /// Deserializes this message.
        /// </summary>
        /// <param name="deserializer">Deserializer used to deserialize objects</param>
        public override void Deserialize(IELabDeserializer deserializer)
        {
            base.Deserialize(deserializer);
            RequestMessageId = deserializer.ReadInt32();
            IsSuccess = deserializer.ReadBoolean();
            ResultMessage = deserializer.ReadStringUTF8();
        }
    }
}
